<?php

namespace App\Http\Controllers\Admin;

use App\Http\Filters\HousingsEditAddressLogFilter;
use App\Models\HousingsEditAddressLog;
use App\Http\Requests\HousingsEditAddressLogRequest;
use App\Http\Resources\HousingsEditAddressLogResource;
use Illuminate\Http\Request;

class HousingsEditAddressLogController extends Controller
{
    public function index(HousingsEditAddressLogFilter $filter)
    {
        $housingsEditAddressLogs = HousingsEditAddressLog::query()
            ->filter($filter)
            ->paginate();

        return $this->ok(HousingsEditAddressLogResource::collection($housingsEditAddressLogs));
    }

    public function create()
    {
        return $this->ok();
    }

    public function store(HousingsEditAddressLogRequest $request)
    {
        $inputs = $request->validated();
        $housingsEditAddressLog = HousingsEditAddressLog::create($inputs);

        return $this->created(HousingsEditAddressLogResource::make($housingsEditAddressLog));
    }

    public function edit(Request $request, HousingsEditAddressLog $housingsEditAddressLog)
    {
        return $this->ok(HousingsEditAddressLogResource::make($housingsEditAddressLog));
    }

    public function update(HousingsEditAddressLogRequest $request, HousingsEditAddressLog $housingsEditAddressLog)
    {
        $inputs = $request->validated();
        $housingsEditAddressLog->update($inputs);

        return $this->created(HousingsEditAddressLogResource::make($housingsEditAddressLog));
    }

    public function destroy(HousingsEditAddressLog $housingsEditAddressLog)
    {
        $housingsEditAddressLog->delete();
        return $this->noContent();
    }
}
